// 纯数字或纯字母或包含数字、字母和小数点的组合
function passwordReg(value) {
	// 匹配纯数字
	const numRegex = /^[0-9]+$/;
	// 匹配纯字母
	const letterRegex = /^[a-zA-Z]+$/;
	// 匹配数字、字母、小数点的组合
	const combinedRegex = /^[0-9a-zA-Z.]+$/;
	if (numRegex.test(value) || letterRegex.test(value) || combinedRegex.test(value)) {
		return false
	}
	return true
}

// CPF验证规则
function validarCPF(input_cpf) {
	//get input
	if (input_cpf) {
		var input = input_cpf.toString();

		var numeros = [];
		var pesos_A = [10, 9, 8, 7, 6, 5, 4, 3, 2];
		var pesos_B = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2];
		var sum = 0;
		var x1 = 0;
		var x2 = 0;

		for (var i = 0; i < 9 && i < input.length; i++) {
			var digito = input[i]
			sum = sum + digito * pesos_A[i];
		}

		//calcula digito 1
		var mod = sum % 11;
		if (mod >= 2) {
			x1 = 11 - mod;
		}

		//calcula digito 2
		sum = 0;
		for (var i = 0; i < 10 && i < input.length; i++) {
			sum = sum + input[i] * pesos_B[i];
		}

		var mod = sum % 11;
		if (mod >= 2) {
			x2 = 11 - mod;
		}

		if (x1 == input[9] && x2 == input[10]) {
			return true;
		} else {
			return false;
		}
	} else {
		return false;
	}
};

export {
	passwordReg,
	validarCPF
}